package com.tchintech.pay.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtils {
	/**
	 * 身份证检测
	 * 
	 * @param str_identify
	 * @return
	 */
	public static boolean checkIdentify(String str_identify) {
		/**
		 * 妫�煡韬唤璇佸彿
		 * 
		 * 15浣�18浣�
		 * 
		 * ^\\d{15}|^\\d{17}([0-9]|X|x)$
		 */
		String regExp = "^\\d{15}|^\\d{17}([0-9]|X|x)$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(str_identify);
		return m.find();
	}

	/**
	 * 名字检测
	 * 
	 * @param str_name
	 * @return
	 */
	public static boolean checkName(String str_name) {
		/**
		 * 妫�煡鍚嶅瓧 ^(([\u4e00-\u9fa5]{2,8})|([a-zA-Z]{2,16}))$
		 */
		String regExp = "^(([\u4e00-\u9fa5]{2,8})|([a-zA-Z]{2,16}))$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(str_name);
		return m.find();
	}

	/**
	 * 电话号码检测
	 * 
	 * @param phoneNumber
	 * @return
	 */
	public static boolean checkPhoneNumber(String phoneNumber) {
		/**
		 * 妫�煡鎵嬫満鍙风爜
		 * 
		 * 鎵嬫満鍙风爜妫�祴姝ｅ垯
		 * 
		 * ^((13[0-9])|(15[^4])|(18[0,1,2,3,5-9])|(17[0-8])|(147))\\d{8}$
		 */
		String regExp = "^((13[0-9])|(15[^4])|(18[0,1,2,3,5-9])|(17[0-8])|(147))\\d{8}$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(phoneNumber);
		return m.find();
	}

	/**
	 * 密码检测长度
	 * 
	 * @param password
	 * @return
	 */
	public static boolean checkPassword(String password) {
		/**
		 * 妫�煡瀵嗙爜
		 * 
		 * 6-10浣� * ^.{6,10}$
		 */

		String regExp = "^.{6,10}$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(password);
		return m.find();
	}

	public static boolean checkPin(String password) {
		/**
		 * 妫�煡楠岃瘉鐮� * 4-6位
		 * 
		 * ^.{6,10}$
		 */
		String regExp = "^.{6}$";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(password);
		return m.find();
	}

	public static boolean checkBankCard(String password) {
		/**
		 * 妫�煡楠岃瘉鐮� * 4-6位
		 * 
		 * ^.{6,10}$
		 */
		String regExp = "^\\d{16}|^\\d{19}";
		Pattern p = Pattern.compile(regExp);
		Matcher m = p.matcher(password);
		return m.find();
	}

}
